# include <iostream>
#include <vector>
using namespace std;

typedef struct node
{
    int value;
    struct node *next;
    struct node *pred;
}node;

vector<node> createlist(int num)
{
    node *head = new node;
    node *pre = head;
    for(int i=0; i< num; i++)
    {
        node *p = new node;
        cout << "Please enter the " << i << "th number:";
        cin >> p->value;
        p -> next = NULL;
        pre->next = p;
        pre = p->pred;
        pre = p;
    }
    return {head, pre};
}

void showlist(node *head)
{
    node *p = head->next;
    while(p != NULL)
    {
        cout << p->value;
        p = p->next;

    }
}

class add_two_lists
{
public:
    node *addTwoNumbers(node *number1_node, node *number2_node)
    {
        int carry = 0;
        int sum = 0;
        node *head = new node;
        node *pre = head;
        node *number1 = number1_node->next;
        node *number2 = number2_node->next;
        while (number1 || number1 || carry)
        {
            sum = 0;
            sum = (number1 ? number1->value : 0) + (number2 ? number2->value : 0) + carry;
            carry = sum / 10;
            node *p = new node;
            p ->value = sum % 10;
            p ->next = NULL;
            pre ->next = p;
            pre = p;
            number1 = number1 ? number1->next : 0;
            number2 = number2 ? number2->next : 0;
        }
        return head;
    }
};

int main()
{
    vector<node> kk00;
    vector<node> kk01;
    cout << "Start creating the first linked list：" << endl;
    kk00 = createlist(3);
    cout << "Start creating the second linked list：" << endl;
    kk01 = createlist(2);
    cout << "the first number is：";
    // showlist(kk00[0]);
    // cout << "\n==========================" << endl;
    // cout << "the second number is：";
    // showlist(kk01);
    // cout << "\n==========================" << endl;
    // add_two_lists add_list;
    // head = add_list.addTwoNumbers(kk00, kk01);
    // cout << "result is ：\n";
    // showlist(head);
    // cout << "\n";
    // return 0;
}